package xyz.xtt.user.constants;

import java.util.concurrent.TimeUnit;

import xyz.xtt.common.starter.cache.CacheConfig;
import xyz.xtt.user.entity.TblUser;
import xyz.xtt.user.entity.TblUserChainAccount;

/**
 * 缓存类枚举
 * 
 * @author huqibo
 * @date 2024/11/28
 */
public enum UserCache implements CacheConfig {

	/**
	 * 用户信息
	 */
	TBL_USER("tblUser", 1, TimeUnit.DAYS, TblUser.class),
	/**
	 * 用户链帐户
	 */
	TBL_USER_CHAIN_ACCOUNT("TblUserChainAccount", 1, TimeUnit.DAYS, TblUserChainAccount.class),;

	/**
	 * 缓存key前缀
	 */
	private String prefix;
	/**
	 * 缓存时长
	 */
	private long ttl;
	/**
	 * 缓存时长单位
	 */
	private TimeUnit timeUnit;
	/**
	 * 缓存序列化对象类型
	 */
	private Class<?> clazz;

	private <T> UserCache(String prefix, long ttl, TimeUnit timeUnit, Class<T> clazz) {
		this.prefix = prefix;
		this.ttl = ttl;
		this.timeUnit = timeUnit;
		this.clazz = clazz;
	}

	@Override
	public String prefix() {
		return prefix;
	}

	@Override
	public long ttl() {
		return ttl;
	}

	@Override
	public TimeUnit timeUnit() {
		return timeUnit;
	}

	@Override
	public Class<?> clazz() {
		return clazz;
	}

}
